package service;

import java.util.List;

import mapper.DeptMapper;
import mapper.UserInfoMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import pojo.Dept;
import pojo.Page;
import pojo.UserInfo;

@Service
public class UserInfoServiceImpl implements UserInfoService {

	@Autowired
	private UserInfoMapper infoMapper;
	
	@Autowired
	private DeptMapper deptMapper;
	
	@Override
	public UserInfo getInfoById(String account,String password, int id) {
		return infoMapper.getInfoById(account,password, id);
	}

	@Override
	public UserInfo getUserByName(String name) {
		return infoMapper.getUserByName(name);
	}

	@Override
	public boolean insert(UserInfo info) {
		return infoMapper.insert(info);
	}

	@Override
	public boolean update(UserInfo info) {
		return infoMapper.update(info);
	}

	@Override
	public boolean del(int id) {
		return infoMapper.del(id);
	}

	@Override
	public Page getPage(String account, int deptId, int pageNo, int pageSize) {
		Page page = new Page();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		page.setCount(infoMapper.count(account, deptId));
		page.setList(infoMapper.getAll(account, deptId, (pageNo-1)*pageSize, pageSize));
		return page;
	}

	@Override
	public List<Dept> getAll() {
		return deptMapper.getAll();
	}

	@Override
	public UserInfo fan(String account) {
		return infoMapper.fan(account);
	}


}
